/** 
 * use for icp amdin login
 * @name login
 * @author yuyunxin511@163.com
 * @version 0.1.0
 */
 
jQuery(function($) {
	$(document).on('click', '.toolbar a[data-target]', function(e) {
		var target = $(this).data('target');
		$('.widget-box.visible').removeClass('visible');//hide others
		$(target).addClass('visible');//show target
		});
	});
	
	//you don't need this, just used for changing background
	jQuery(function($) {
		$('#btn-login-dark').on('click', function(e) {
		$('body').attr('class', 'login-layout');
		$('#id-text2').attr('class', 'white');
		$('#id-company-text').attr('class', 'blue');
	});
	
	$('#btn-login-light').on('click', function(e) {
		$('body').attr('class', 'login-layout light-login');
		$('#id-text2').attr('class', 'grey');
		$('#id-company-text').attr('class', 'blue');
	});
	
	$('#btn-login-blur').on('click', function(e) {
		$('body').attr('class', 'login-layout blur-login');
		$('#id-text2').attr('class', 'white');
		$('#id-company-text').attr('class', 'light-blue');
	});
	
	$('#login_btn').on('click', function(e) {
		var login_name = $.trim($('#login_name').val());
		if (login_name == "") {
			alert('请输入登录名');
			$('#login_name').focus();
			return;
		}
		
		var login_pass = $.trim($('#login_pass').val());
		if (login_pass == "") {
			alert("请输入登录密码");
			$('#login_pass').focus();
			return;
		}
		var postData="lname="+login_name+"&lpass="+login_pass;
		req_ajax(postData, '/icp/index.php/admin/login/login', login_success);
	});
});

function muser_logout() {
	req_ajax_get('/icp/index.php/admin/login/logout', logout_success);
}

function logout_success(result, status) {
	jsonData = eval(result);//生成json对象
    if (jsonData.status == 1) {
        window.location.href='/icp/index.php/admin/login/';
    } else {
		alert(jsonData.content);
	}
}

function login_success(result, status) {
	jsonData = eval(result);//生成json对象
	alert(jsonData.status);
    if (jsonData.status == 1) {
        window.location.href='/icp/index.php/admin/index/index';
    } else {
		alert(jsonData.content);
	}
}